package com.qisimanxiang.dalaran.zuul.custom.ribbon;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider;
import org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Set;

/**
 * @author wangmeng
 * @date created in 3:47 下午 2019/9/17
 * @modified by
 */
@Component
@Configuration
public class RibbonCustomConfig {
    @Autowired(required = false)
    private Set<FallbackProvider> zuulFallbackProviders = Collections.emptySet();

    @Bean
    public RibbonCommandFactory<?> ribbonCommandFactory(
            SpringClientFactory clientFactory, ZuulProperties zuulProperties) {
        return new CustomHttpClientRibbonCommandFactory(clientFactory, zuulProperties,
                zuulFallbackProviders);
    }
}
